package cn.lyjuan.payment.third.base.pay.chl.impl.ali.enums;

import cn.lyjuan.base.util.StringUtils;

import java.io.Serializable;

/**
 * 支付宝支付枚举类型
 */
public enum AliServiceEnum
{
    /**
     * 手机APP
     */
    APP("alipay.trade.app.pay")
    /**
     * 手机H5
     */
    , WAP("alipay.wap.create.direct.pay.by.user")
    /**
     * 电脑WEB或二维码
     */
    , WEB_QRCODE("create_direct_pay_by_user")

    ;

    private String value;

    public String getValue()
    {
        return value;
    }

    AliServiceEnum(String value)
    {
        this.value = value;
    }

    public static AliServiceEnum parse(String service)
    {
        if (StringUtils.isNull(service))
            throw new RuntimeException("ali service can not be null");

        if (service.equalsIgnoreCase(APP.value))
            return APP;

        if (service.equalsIgnoreCase(WAP.value))
            return WAP;

        if (service.equalsIgnoreCase(WEB_QRCODE.value))
            return WEB_QRCODE;

        throw new RuntimeException("ali service unsupported: " + service);
    }
}
